using MediatR;
using SumerCoreDevOps.Application.GitTriggers.Commands;
using SumerCoreDevOps.Infrastructure.GitTrigger;

namespace SumerCoreDevOps.Application.GitTriggers.Handlers;

/// <summary>
/// 删除 Git 触发规则命令处理器
/// </summary>
public class DeleteGitTriggerRuleCommandHandler : IRequestHandler<DeleteGitTriggerRuleCommand, Unit>
{
    private readonly GitTriggerRuleManager _ruleManager;

    public DeleteGitTriggerRuleCommandHandler(GitTriggerRuleManager ruleManager)
    {
        _ruleManager = ruleManager;
    }

    public async Task<Unit> Handle(DeleteGitTriggerRuleCommand request, CancellationToken cancellationToken)
    {
        await _ruleManager.DeleteRuleAsync(request.Id);
        return Unit.Value;
    }
}
